package com.controller;

import com.controller.vo.ResultVO;
import com.entity.Notification;
import com.service.NotificationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * ClassName: NotificationController
 * Description:
 *
 * @author L_Z_R
 * @version 1.0
 * @create 2025/06/18 09:52
 */
@RestController
public class NotificationController extends BaseController{
    @Autowired
    private NotificationService notificationService;

    @GetMapping("/notification")
    public ResultVO<List<Notification>> getNotifications(@RequestParam("receiverId") Integer receiverId, @RequestParam("type") byte type) {
        List<Notification> notifications = notificationService.selectByType(receiverId, type);
        return success(notifications);
    }
    @GetMapping("/unreadCount")
    public ResultVO<Integer> getUnreadCount(@RequestParam("receiverId") Integer receiverId) {
        int count = notificationService.countUnreadByUserId(receiverId);
        return success(count);
    }
}
